Introduction to R and RStudio
2025-11-28
. . .
/Users/yourname/Desktop/someproject/data/somefile.csv (Mac/Linux)C:\\Users\\yourname\\Desktop\\someproject\\data\\somefile.csv (Windows)/ (R will convert it)\\ is a “escape character”, with a special meaningdata/somefile.csv)
. . .
../somefile.csv”: find “somefile.csv” one level down../../somefile.csv”: find “somefile.csv” two levels down./somefile.csv”: find “somefile.csv” in the current level (not so useful, it is identical to “somefile.csv”)~/somefile.csv”: find “somefile.csv” in your home directory.R)/Users/yourname). . .
.Rproj). . .
Tell the computer to save an object (a number, a string, a spreadsheet) with a name.
Creating variables in R is very straightforward:
<-Everything is an object in R, and can be assigned to a variable name
character: “some text”numeric: e.g., 2.1integer: e.g., 2Llogical: TRUE/FALSEfactor: e.g., factor(“amsterdam”)vector: c(2, 4, 2)list: list(first_col = 1, second = “a”, third = TRUE)matrix: matrix(c(4, 4, 4, 4), nrow = 2, ncol = 2)data.frame: The most important ~ spreadsheetEverything that is published on the Comprehensive R Archive Network (CRAN) and is aimed at R users, must be accompanied by a help file.
If you know the name of the function that performs an operation, e.g. anova(), then you just type ?anova or help(anova) in the console, or use the “Help” menu.
If you do not know the name of the function: type ?? followed by your search criterion. For example ??anova returns a list of all help pages that contain the word ‘anova’
Alternatively, the internet will tell you almost everything you’d like to know and sites such as http://www.stackoverflow.com and http://www.stackexchange.com, as well as Google and LLM can be of tremendous help.
R related issues; use ‘R:’ as a prefix in your search termYou just use type the name you have given to the object
For example, we assigned the value 100 to object a.
Hint: the readr:: is optional when the package is loaded
Goal: Get used to RStudio using R as a calculator, and install one library
CC BY-NC-SA 4.0 — hanneoberman.github.io/rijksR